Skip to content

JWL equation of state: single-material and multi-fluid mixture implementation#1586

Draft
fahnab666 wants to merge 6 commits into
MFlowCode:masterfrom
fahnab666:jwl-upstream-rebase
Draft

JWL equation of state: single-material and multi-fluid mixture implementation#1586
fahnab666 wants to merge 6 commits into
MFlowCode:masterfrom
fahnab666:jwl-upstream-rebase

Conversation

@fahnab666

Copy link
Copy Markdown

Description

Implements the Jones--Wilkins--Lee (JWL) equation of state in MFC for detonation-products modeling, including:

  • single-material JWL cases,

  • multi-fluid JWL/ideal-gas mixtures,

  • four mixture closures,

  • GPU-resident JWL parameter tables,

  • quantitative verification tests.

Closes #.

Type of change

  •  New feature


JWL EOS

The JWL pressure is implemented as a Mie--Gruneisen EOS with a two-exponential cold curve:

p = p_cold(rho) + omega*rho*e

where

p_cold(rho) =
    A*(1 - omega/(R1*V))*exp(-R1*V)
  + B*(1 - omega/(R2*V))*exp(-R2*V)

V = rho0/rho

The isentropic sound speed uses the Rocflu/Stanley form:

c^2 = dp_cold/drho + omega*(e + p/rho)

This requires only p and rho, with no explicit temperature evaluation, keeping the EOS inexpensive on the GPU hot path.


EOS selection

Each fluid selects its EOS using fluid_pp(i)%eos.

Value EOS Notes
1 Stiffened gas Default
2 JWL Requires fluid_pp(i)%jwl_* parameters

Sub-cold-curve states, where p < p_cold(rho), are intentionally skipped because the temperature floor clamps T = 0; therefore, exact round-trip identity is not expected.


Checklist

  •  I added or updated tests for new behavior.

  •  I updated documentation if user-facing behavior changed.

  •  GPU results match CPU results.

  •  Tested on NVIDIA GPU or AMD GPU.

Description

Implements the Jones--Wilkins--Lee (JWL) equation of state in MFC for detonation-products modeling, including:

  • single-material JWL cases,

  • multi-fluid JWL/ideal-gas mixtures,

  • four mixture closures,

  • GPU-resident JWL parameter tables,

  • quantitative verification tests.

Closes #.

Type of change

  •  New feature


JWL EOS

The JWL pressure is implemented as a Mie--Gruneisen EOS with a two-exponential cold curve:

p = p_cold(rho) + omega*rho*e

where

p_cold(rho) =
    A*(1 - omega/(R1*V))*exp(-R1*V)
  + B*(1 - omega/(R2*V))*exp(-R2*V)

V = rho0/rho

The isentropic sound speed uses the Rocflu/Stanley form:

c^2 = dp_cold/drho + omega*(e + p/rho)

This requires only p and rho, with no explicit temperature evaluation, keeping the EOS inexpensive on the GPU hot path.


EOS selection

Each fluid selects its EOS using fluid_pp(i)%eos.

Value EOS Notes
1 Stiffened gas Default
2 JWL Requires fluid_pp(i)%jwl_* parameters

Sub-cold-curve states, where p < p_cold(rho), are intentionally skipped because the temperature floor clamps T = 0; therefore, exact round-trip identity is not expected.


Checklist

  •  I added or updated tests for new behavior.

  •  I updated documentation if user-facing behavior changed.

  •  GPU results match CPU results.

  •  Tested on NVIDIA GPU or AMD GPU.

Add Jones-Wilkins-Lee equation of state with four mixture closures
(isobaric, Kuhl-Khasainov, p-T equilibrium, Rocflu blend) via
jwl_mix_type. New shared m_jwl module, per-fluid eos selector,
GPU-resident parameter arrays, example cases, and inverse-function
test suite.
@fahnab666

Copy link
Copy Markdown
Author

@claude full review

Fahad Nabid added 2 commits June 12, 2026 13:44
Without this, the device copy of jwl_mix_type was uninitialized; non-zero
mixture closures (Kuhl, p-T equil, Rocflu) silently executed the wrong
branch on GPU.
… rocflu fix

- s_initialize_jwl_module: add f_is_default sentinel checks on all JWL
  parameters, positivity checks on R1/R2/omega/rho0, n_jwl>1 guard;
  upgrade cv check with f_is_default; use local use statements
  (m_mpi_common, m_helper_basic) instead of module-level import
- s_jwl_sound_speed_squared: refactor to reuse s_jwl_pcold /
  s_jwl_dpcold_drho helpers instead of inlining the same algebra
- s_jwl_ptequil_pressure_er/energy_pr: add 1e-12 early-exit to both
  bisection loops; add bracket sign check in energy_pr fallback
- s_jwl_rocflu_pressure_er/energy_pr: widen high-Y guard to
  1-1e-4 (symmetric with low-Y guard) to close the 0.99 discontinuity
- m_variables_conversion: remove dead s_mpi_allreduce_integer_sum import
- tests: add golden files for jwl_single_material_shocktube,
  1D/2D jwl_mixture_test
@fahnab666 fahnab666 force-pushed the jwl-upstream-rebase branch from 73700a5 to d83068f Compare June 13, 2026 02:05
Fahad Nabid added 2 commits June 13, 2026 00:27
…s (5-eq model)

Wire the JWL EOS into the solver hot path for the five-equation model
(model_eqns = 2, Allaire et al. JCP 2002). All changes are guarded by
jwl_idx > 0 and model_eqns == model_eqns_5eq so non-JWL cases are
unaffected.

m_variables_conversion:
- s_convert_conservative_to_primitive_variables: after s_compute_pressure
  gives the stiffened-gas pressure, override it with s_jwl_mix_pressure_er
  using Y = alpha_rho(jwl_idx)/rho and alpha = alpha(jwl_idx). Without
  this, the solver uses the wrong EOS to recover pressure from conserved
  variables, giving thermodynamically inconsistent primitive fields.
- s_convert_primitive_to_conservative_variables: add JWL branch that
  computes E = rho*e_mix(rho,p,Y,alpha) + 0.5*rho|u|^2 + qv via
  s_jwl_mix_energy_pr instead of the stiffened-gas E = gamma*p + pi_inf
  formula, keeping prim->cons consistent with cons->prim.
- s_compute_speed_of_sound: add JWL branch using
  s_jwl_mixture_sound_speed_squared (frozen mass-weighted rule). Accepts
  an optional alpha_rho_j argument for the correct Y_j = alpha_rho_j/rho;
  falls back to the rho0 proxy alpha_j*rho0/rho when not supplied (e.g.
  avg-state calls).
- Export s_jwl_mixture_sound_speed_squared via the module public list.

m_riemann_solver_hll / m_riemann_solver_hllc:
- Add use m_jwl to both modules.
- In every E_L/E_R reconstruction block: when jwl_idx > 0 and 5-eq,
  compute e_L/e_R from pressure via s_jwl_mix_energy_pr and form
  E = rho*e + 0.5*rho|u|^2 instead of the stiffened-gas gamma*p + pi_inf
  formula. This keeps the Riemann wave-speed estimates thermodynamically
  consistent with the JWL EOS for both HLL and HLLC solvers.
- In m_riemann_solver_hll: pass alpha_rho_j to both s_compute_speed_of_sound
  calls so the sound speed uses the actual phasic partial density for Y_j
  rather than the rho0 proxy.
Convert the 1D JWL CJ products example from the slow six-equation pTg relaxation setup to a cheap five-equation JWL mixture smoke case. The case now uses fixed timestepping, HLL, periodic boundaries, and an 8-step stop so it runs in seconds instead of spending minutes in relaxation/adaptive CFL work.

Finish the JWL sound-speed and energy consistency wiring by passing actual JWL partial densities through the HLL sound-speed calls, using JWL inverse energy during primitive/flux conversion, and adding guards for invalid JWL pressure, energy, and RK energy updates.

Add the generated 52A7542F golden test files for the updated jwl_cj_products case. Validation before push: ./mfc.sh build -j 8, ./mfc.sh test --generate --no-build -f 52A7542F -t 52A7542F -j 1, and the commit-hook precheck all passed.
@fahnab666 fahnab666 force-pushed the jwl-upstream-rebase branch from 0998f4b to cdb34a7 Compare June 13, 2026 09:03
… case to 5-eq

s_compute_speed_of_sound used 'present(alpha_rho_j) .and. alpha_rho_j == alpha_rho_j'
in a single expression. Fortran does not guarantee short-circuit evaluation of .and.,
so gfortran evaluated alpha_rho_j (null pointer) even when it was absent, causing a
SIGSEGV in every HLLC test. Fix: separate into a nested if-block, compute the
rho0-proxy Y_j first, then conditionally override when alpha_rho_j is present and
not NaN.

Also converts examples/1D_jwl_cj_products from the expensive 6-equation pTg relaxation
model (model_eqns=3, relax_model=6) to the 5-equation model (model_eqns=2) with the
isobaric JWL closure, restoring physical CJ detonation parameters (D=6900 m/s,
CR=1.80) that keep the initial pressure (34.5 GPa) above the JWL cold curve (7.1 GPa).

All four JWL tests now pass: 52A7542F, E3460991, DB95E4F7, 25B9827F.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant